
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>  
    <button id="fetchButton">Fetch Data</button>  
    <p id="responseMessage"></p>  
  
    <script>  
        document.getElementById('fetchButton').addEventListener('click', async function() {  
            try {  
                const response = await fetch('http://localhost:4000/');  
                console.log("response的内容是",response)
                if (!response.ok) {  
                    throw new Error('Network response was not ok');  
                }  
                const data = await response.json();
                console.log("获取打印数据",data)
                document.getElementById('responseMessage').innerHTML = data.message;  
            } catch (error) {  
                console.error('There was a problem with the fetch operation:', error);  
            }  
        });  
    </script>  
</body>
</html>